/*
 * PersistenceObject.java
 *
 *Create on 20080114
 */

package com.gln.bloger.pojos;

import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
/**
 *
 * @author renxj
 */
public abstract class Entity implements Serializable {
    public abstract String getId();
    public abstract void setId(String id);
    public abstract void setData(Entity other);
    public boolean equals(Object o) {
        return EqualsBuilder.reflectionEquals(this, o);
    }
     // TODO: how efficient is this?
    public String toString() {
        try {
            // this may throw an exception if called by a thread that
            return ToStringBuilder.reflectionToString(
                    this, ToStringStyle.MULTI_LINE_STYLE);
        } catch (Throwable e) {
            // alternative toString() implementation used in case of exception
            return getClass().getName() + ":" + getId();
        }
    }
}
